Here is some code using java 6 to get you started: JSONObject jo = new JSONObject(); jo.put("firstName", "John"); jo.put("lastName", "Doe"); JSONArray ja ... ... <看更多>
A JSONArray is an ordered sequence of values. Its external text form is a string wrapped in square brackets with commas separating the values. ... <看更多>
We iterate over the plant objects and create a JsonArray, full of JsonObjects. We write those JsonObjects to a servlet, using a PrintWriter, ... ... <看更多>
You should not catch exceptions and discard them silently. This code has no chance of throwing an exception, therefore you should just let ... ... <看更多>